/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  return str.trim() > 0
}


export function requiredFormValidate(rule, value, callback) {
  if (["", null, undefined].includes(value)) {
    callback(new Error("此项必填"));
  } else {
    callback();
  }
};
export function bannerListValidate(rule, value, callback) {
  if (!Array.isArray(value) || value.length == 0) {
    callback(new Error("请上传轮播图"));
  } else {
    callback();
  }
};